<#assign frm = form />
<#macro buildForm _form=frm fieldPrefix="model.">
			<fieldset>
				<ul>
					<#list _form.fields as field>
						<li>
							<label>
								${field.label}:
							</label>
							<#switch field.type.name>
								<#case "java.util.Date">
									<@s.textfield name="${fieldPrefix + field.name}" cssClass="datePicker" />
									<#break />
								<#case "java.lang.Boolean">
									<@s.checkbox name="${fieldPrefix + field.name}" />
									<#break />
								<#default>
									<#switch field.renderer!"">
										<#case "autocomplete">
											<@s.textfield onchange="if(!$(this).val()) $(this).next('input').val('');" name="${fieldPrefix + field.name}" value="${model[field.name]!''}" cssClass="autocomplete {data: '${request.contextPath}/lookup/${field.type.name?replace('.','~')}'}" name="" />
											<@s.hidden name="related['${field.name}']" value="${((model[field.name]!{}).key)!''}" />
											<#if field.editDomo>
												[<a class="thickbox" onclick="var key = $(this).prev('input').val(); if(!key) { alert('nothing selected!'); return false; } else { this.href=this.href.replace(/\?/,key+'?'); return true; }" href="${request.contextPath}${field.controller}/?&decorator=modal&TB_iframe=true&height=450&width=550">edit</a>]
											</#if>
											<#break />
										<#case "select">
											<#assign currentVal=(((model[field.name]!{}).key)!'')?trim />
											<select name="related['${field.name}']" value="${currentVal}" list="entities" >
												<#list action.findAll(field.type) as ent>
														<option value="${ent.key}" <#if ent.key = currentVal>selected</#if>>${ent}</option>
												</#list>
											</select>
											<#if field.editDomo>
												[<a class="thickbox" onclick="var key = $(this).prev('input').val(); if(!key) { alert('nothing selected!'); return false; } else { this.href=this.href.replace(/\?/,key+'?'); return true; }" href="${request.contextPath}${field.controller}/?&decorator=modal&TB_iframe=true&height=450&width=550">edit</a>]
											</#if>
											<#break />
										<#default>
											<@s.textfield name="${fieldPrefix + field.name}" />
									</#switch>
							</#switch>
							<@fieldError fieldPrefix + field.name />
						</li>
					</#list>
				</ul>
			</fieldset>
</#macro>

<#macro pageErrors debugFields=false>
	<#if actionErrors?? && actionErrors?size &gt; 0>
		<@renderErrors actionErrors />
	</#if>
	<#if debugFields>
		<hr />
		<#list fieldErrors.keySet() as error>
		field Error: ${error}
			<@renderErrors fieldErrors.get(error) />
		<HR />
		</#list>
		<hr />
	</#if>
</#macro>

<#macro renderErrors errors>
	<#list errors as error>
		<div class="error">
			${error}
		</div>
	</#list>
</#macro>

<#macro fieldError fieldName>
	<#if fieldErrors?? && fieldErrors.get(fieldName)??>
		<@renderErrors fieldErrors.get(fieldName) />
	</#if>
</#macro>
